package cn.csxw.openchina.ui.adapter;

import android.app.Activity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.bumptech.glide.Glide;

import butterknife.BindView;
import cn.csxw.openchina.R;
import cn.csxw.openchina.base.BaseRecAdapter;
import cn.csxw.openchina.entity.bean.CommentBean;
import cn.csxw.openchina.ui.view.CircleImageView;
import cn.csxw.openchina.utils.Global;

/**
 * 动弹评论的Adapter
 */

public class MoveCommentAdapter extends BaseRecAdapter<CommentBean> {
    private Activity activity;

    public MoveCommentAdapter(final Activity activity) {
        this.activity = activity;

    }

    @Override
    protected void onItemClick(View v, int position) {

    }

    @Override
    protected BaseViewHolder getViewHolder(View itemView) {
        return new CommentHolder(itemView);
    }

    @Override
    protected View getItemView(ViewGroup parent) {
        View itemView = Global.inflate(R.layout.view_move_comment_item, parent);
        return itemView;
    }

    class CommentHolder extends BaseViewHolder {

        @BindView(R.id.iv_move_comment_item_photo)
        CircleImageView mMoveCommentItemPhoto;
        @BindView(R.id.tv_move_comment_item_name)
        TextView mMoveCommentItemName;
        @BindView(R.id.tv_move_comment_item_time)
        TextView mMoveCommentItemTime;
        @BindView(R.id.tv_move_comment_item_content)
        TextView mMoveCommentItemContent;

        public CommentHolder(View itemView) {
            super(itemView);
        }

        @Override
        public void setData(CommentBean commentBean, int Position) {
            mMoveCommentItemContent.setText(commentBean.content);
            Glide.with(activity).load(commentBean.portrait).into(mMoveCommentItemPhoto);
            mMoveCommentItemName.setText(commentBean.author);
            mMoveCommentItemName.setMaxEms(10);
            mMoveCommentItemTime.setText(commentBean.pubDate);
        }
    }

}
